import pandas as pd
import numpy as np
from data import Dataset
from utils import *
import os
from tabulate import tabulate

class Speculate():
    def __init__(self):
        self.df = pd.DataFrame() # 预测数据
        self.data = Dataset()
        
    
    def readData(self,r_path):
        '''
        1、r_path: 通信达导出的日线数据所在的目录
        2、生成函数,每次获取一支股票2015年至今的收盘数据
        '''
        files = os.listdir(r_path)
        for f_path in files:
            f_path = os.path.join('日线_data',f_path)
            df = pd.read_csv(f_path
                             ,header=None
                             ,index_col=False
                             ,encoding='gbk'
                             ,names=['trade_date','open','high','low','close','vol','amount']).dropna()
            df = df.sort_values('trade_date').reset_index(drop=True)
            yield df['close']